<?php

##################################################
#
# Copyright (c) 2006 Maxim Mueller
# Copyright (c) 2007 Ron Miller, OIC Group, Inc.
# Copyright (c) 2009 Immanuel, ABSoft, Inc
#
##################################################

if (!defined('EXPONENT')) exit('');
$col_id=-1;
if (isset($_REQUEST['id']))
  $col_id=$_REQUEST['id'];
if ($col_id == 0)
  $col_id = -1;
// get all file in this collection
$items = $db->selectObjects('file', 'collection_id=' . $col_id);

if (exponent_sessions_loggedIn()) {

  foreach ($items as $item)
  {
		$db->delete('file', 'id=' . $item->id);
		unlink(BASE . $item->directory . "/" . $item->filename);	
	}
	// delete collection
	$item=$db->selectObject('file_collection','id='.$col_id);
	$db->delete('file_collection','id='.$col_id);
	rmdir(BASE . "files/".$item->name);
} 
header('Location: '.URL_FULL.'modules/filemanagermodule/actions/picker.php');
?>
